<!DOCTYPE html>
<html>
<head>
    <title>查询</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">

    <meta name="description" content="Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.
">
    <link rel="stylesheet" href="../studentPhoneLogin/css/weui.css">
    <link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.min.css">
    <link rel="stylesheet" href="../studentPhoneLogin/css/demos.css">
    <link rel="stylesheet" href="https://cdn.bootcss.com/weui/0.4.3/style/weui.min.css" type="text/css">
    <style>
        .placeholder {
            margin: 5px;
            padding: 0 10px;
            background-color: #ebebeb;
            height: 2.3em;
            line-height: 2.3em;
            text-align: left;
            color: #cfcfcf;
        }
    </style>
</head>

<body ontouchstart>

<header class='demos-header' style="padding-top: 20px;padding-bottom: 20px;">
    <h1 class="demos-title">
        历史课程 </h1>
</header>

<div class="weui-form-preview">
    <div class="weui-form-preview__bd">
        <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">选课时间</label>
            <em class="weui-form-preview__value">2018-11-07 18:29:14</em>
        </div>
        <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">教室</label>
            <em class="weui-form-preview__value">301</em>
        </div>
        <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">上课时间</label>
            <em class="weui-form-preview__value">上午1~2节(08:00-09:35)</em>
        </div>
        <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">课程内容</label>
            <em class="weui-form-preview__value">RC暂态</em>
        </div>


        <div class="weui-form-preview__ft">
            <button type="submit" class="weui-form-preview__btn weui-form-preview__btn_primary" onclick="cancel(45)">
                取消课程
            </button>
            <button type="submit" class="weui-form-preview__btn weui-form-preview__btn_primary"
                    onclick="historyCourse()">历史课程
            </button>
        </div>
    </div>

    <script src="../studentPhoneLogin/js/jquery-2.1.4.js"></script>
    <script src="../studentPhoneLogin/js/fastclick.js"></script>
    <script>
        $(function () {
            FastClick.attach(document.body);
        });
    </script>

    <script src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.min.js"></script>
    <script>

        function getCookie(cname) {
            var name = cname + "=";
            var ca = document.cookie.split(';');
            for (var i = 0; i < ca.length; i++) {
                var c = ca[i].trim();
                if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
            }
            return "";
        }


        function cancel(id) {
            var alreadyChoiceCourse = getCookie("alreadyChoiceCourse");
            if (alreadyChoiceCourse == "") {
                $.toast("未选课,禁止操作", "forbidden");
            } else {
                $.confirm({
                    title: '确定取消该课程?',
                    text: '一天只能选课一次,取消无法恢复!',
                    onOK: function () {
                        //点击确认
                        var alreadyCancelCourse = getCookie("alreadyCancelCourse");
                        if (alreadyCancelCourse != "") {
                            $.toast("你已经取消今日课程了,请不要重新操作!", "text");
                        } else {
                            $.post('../studentPhoneLogin/cancelCourse.php', {'id': id}, function (res) {
                                if (res.status == 0) {

                                    $.toast(res.msg, "text");

                                } else {

                                    $.toast(res.msg, "text");
                                    setTimeout(function () {
                                        window.location.href = "alreadyCancelCourse.php";
                                    }, 1000);
                                }
                            }, 'json');
                        }
                    },
                    onCancel: function () {
                    }
                });
            }
        }

        function historyCourse() {
            setTimeout(function () {
                window.location.href = 'historyCourse.php';
            }, 1000);
        }


    </script>
</body>
</html>
